package com.Action;

import java.util.List;
import java.sql.SQLException;
import java.util.ArrayList;

import com.implement.InputDB;
import com.jdbc.Jdbc;
import com.project.bean.Contract;

public class ContractInputDB implements InputDB {

	

	@Override
	public int InputDB(List  obj) {
		List<Contract> fcl = new ArrayList<>();
		fcl = obj;
		
		
		for(Contract c:fcl) {
			String cid=c.getContractid();
			String id =c.getId();
			String cname=c.getChinesename();
			String ename=c.getEnglishname();
			String sex=c.getSex();
			String birthday=c.getBirthday();
			String coursename = c.getCoursename();
			String totalclass = c.getTotalclass();
			String restclass = c.getRestclass();
			String tuition =c.getTuition();
			String chargestate =c.getChargestate();
			String signtype = c.getSigntype();
			String counselor =c.getCounselor();
			String pcounselor = c.getPhonecounselor();
			String cteacher =c.getChineseteacher();
			String eteacher = c.getEnglishteacher();
			String username = c.getUsername();
			String insert = "insert into contract(contractid, id, chinesename,englishname,sex,birthday,coursename,totalclass,restclass,tuition,"
					+ "chargestate,signtype,counselor,phonecounselor,chineseteacher,englishteacher,username)values('"+cid+"','"+id+"','"+cname+"','"+ename+"',"
							+ "'"+sex+"','"+birthday+"','"+coursename+"','"+totalclass+"','"+restclass+"','"+tuition+"','"+chargestate+"','"+signtype+"',"
									+ "'"+counselor+"','"+pcounselor+"','"+cteacher+"','"+eteacher+"','"+username+"')";
	        System.out.println(insert);
			Jdbc j1 = null;
		
			try {
				j1= new Jdbc(insert);
				
			} catch (ClassNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} catch (SQLException e) {
				
				e.printStackTrace();
				return 0;
			}
			
				
			
		}
		return 1;
	}


	

	

}
